package com.usian.admin.controller.v1;


import com.usian.admin.service.AdChannelService;
import com.usian.api.admin.AdchannelControllerApi;
import com.usian.model.admin.dtos.ChannelDto;
import com.usian.model.admin.pojos.AdChannel;
import com.usian.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/channel")
public class AdChannelController implements AdchannelControllerApi {


    @Autowired
    private AdChannelService adChannelService;

    @RequestMapping("list")
    @Override
    public ResponseResult findByNameAndPage(@RequestBody ChannelDto channelDto) {
        return adChannelService.findByNameAndPage(channelDto);
    }


    @RequestMapping("save")
    @Override
    public ResponseResult save(@RequestBody AdChannel channel) {
        return adChannelService.saveChannel(channel);
    }


    @RequestMapping("update")
    @Override
    public ResponseResult update(@RequestBody AdChannel adChannel) {
        return adChannelService.update(adChannel);
    }

    // localhost:8080/api/v1/channel/del/1
    // restful api
    @Override
    @GetMapping("/del/{id}")
    public ResponseResult deleteById(@PathVariable("id") Integer id) {
        return adChannelService.deleteById(id);
    }
}
